<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>

<body>
    <script>
        var str = "aaaAbbABB12ffFFF385456sJJs";
        var num1 = 0;
        var num2 = 0;
        var num3 = 0;
        for (var i = 0; i < str.length; i++) {
            var j = str.indexOf(i);
            if (j >= "A" && j <= "Z") {
                num1++;
            } else if (j >= "a" && j <= "z") {
                num2++;
            } else if (j >= "0" && j <= "9") {
                num3++;
            }

            // if(str1 !==-1){
            //     num1++;
            //     // console.log("位置 "+str1);
            //     str1=str.indexOf(i,str1+1);
            // }
        }
        console.log("大写出现次数" + num1);
        console.log("小写出现次数" + num2);
        console.log("数字出现次数" + num3);

        //用charAt写
        var str_big = "aaaAbbABB123ssssGGG11333";
        var daxie = 0;
        var xiaoxie = 0;
        var shuzi = 0;
        for (var a = 0; a < str_big.length; a++) {
            var b = str_big.charAt(a);
            if (b >= "A" && b <= "Z") {
                daxie++;
            } else if (b >= "a" && b <= "z") {
                xiaoxie++;
            } else if (b >= "0" && b <= "9") {
                shuzi++;
            }
        }
        console.log("大写出现次数为：" + daxie);
        console.log("小写出现次数为：" + xiaoxie);
        console.log("数字出现次数为：" + shuzi);
    </script>
</body>

</html>